import 'package:app/util/StringUtils.dart';
import 'package:app/util/http.dart';
import 'package:flutter/material.dart';

class MaterialApi{
  BuildContext? context;

  static MaterialApi of(BuildContext? context) {
    MaterialApi materialApi = MaterialApi();
    materialApi.context = context;
    return materialApi;
  }

  /// 查找物料列表
  Future<dynamic> list(String code, {String pickStatus = ''}) async {
    return ApiService.of(context).get('/lgs/material/list/$code${StringUtils.isNotNull(pickStatus) ? '?pickStatus=$pickStatus' : ''}');
  }

  /// 查找库存物料
  Future<dynamic> inventory(String code) async{
    return ApiService.of(context).get('/lgs/material/inventory/${code}');
  }

  /// 查询退料单list
  Future<dynamic> materialBacks(code) async{
    return await ApiService.of(context).get('lgs/material/backs/'+code);
  }

  /// 生产退料-开始配送 --无引用
  Future<dynamic> startDelivery(station) async{
    return await ApiService.of(context).put('/lgs/material/return/delivery/'+station,null);
  }

  /// 生产退料-绑定物料
  Future<dynamic> bind(data) async{
    return await ApiService.of(context).put('/lgs/material/bind', data);
  }

  /// 生产退料-解绑物料
  Future<dynamic> unbind(station) async{
    return await ApiService.of(context).delete('/lgs/material/unbind/'+station);
  }
}